﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

namespace MyWebPagesStarterKit
{
    /// <summary>
    /// Summary description for RBlogSidebar
    /// </summary>
    public class RBlogSidebar : Section<RBlogSidebar.Data>
    {
        public RBlogSidebar() : base(){}
        public RBlogSidebar(string id): base(id){}

        public DataView GetItems(string PageID)
        {
            WebPage page = new WebPage(PageID);
            RBlog blog = null;
            foreach (ISection section in page.Sections)
            {
                if (section.GetType().FullName.Contains("MyWebPagesStarterKit.RBlog"))
                {
                    blog = (RBlog)SectionLoader.GetInstance().LoadSection(section.SectionId);
                    return blog.GetEntriesReadonly();
                }
            }
            return null;
        }

        public override List<SearchResult> Search(string searchString, WebPage page)
        {
            return new List<SearchResult>();
        }

        public override Position Position
        {
            get { return _data.Position; }
            set { _data.Position = value; }
        }

        public override bool IsOnline
        {
            get { return _data.IsOnline; }
            set { _data.IsOnline = value; }
        }

        public string PageID
        {
            get { return base._data.PageID; }
            set { base._data.PageID = value; }
        }

        public bool ShowCalendar
        {
            get { return _data.ShowCalendar; }
            set { _data.ShowCalendar = value; }
        }

        public class Data
        {
            public Position Position;
            public bool IsOnline = false;
            public string PageID;
            public bool ShowCalendar = false;
        }
    }
}
